package com.realife.ysuper.controller;

import com.realife.common.utils.R;
import com.realife.ysuper.entity.ApplicationEntity;
import com.realife.ysuper.service.ApplicationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;



/**
 * 服务信息表，记录微服务的id，名称，密文，用来做服务认证
 *
 * @author Albert
 * @email 15962463559@163.com
 * @date 2020-06-05 10:04:16
 */
@Slf4j
@RestController
@RequestMapping("/ysuper/application")
public class ApplicationController {

    @Autowired
    private ApplicationService applicationService;



    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("ysuper:application:info")
    public R info(@PathVariable("id") Integer id){
		ApplicationEntity application = applicationService.getById(id);

        return R.ok().put("application", application);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("ysuper:application:save")
    public R save(@RequestBody ApplicationEntity application){
		applicationService.save(application);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("ysuper:application:update")
    public R update(@RequestBody ApplicationEntity application){
		applicationService.updateById(application);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("ysuper:application:delete")
    public R delete(@RequestBody Integer[] ids){
		applicationService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
